#ifndef ARC_NODE_HPP
#define ARC_NODE_HPP

#include <memory>

namespace CachePool
{
    template <typename Key, typename Value>
    class ArcNode
    {
    public:
        ArcNode() : accessCount_(1), prev_(nullptr), next_(nullptr) {}

        ArcNode(const Key &key, const Value &value)
            : key_(key), value_(value), accessCount_(1), prev_(nullptr), next_(nullptr)
        {
        }

        // Setters
        void setValue(const Value &value)
        {
            this->value_ = value;
        }

        void incrementAccessCount()
        {
            ++this->accessCount_;
        }

        // Getters
        Key getKey() const
        {
            return this->key_;
        }

        Value getValue() const
        {
            return this->value_;
        }

        size_t getAccessCount() const
        {
            return this->accessCount_;
        }

        // template <typename Key, typename Value>// 前向声明
        // class ArcLruPart;
        // friend class ArcLruPart<Key, Value>;
        template <typename K, typename V>
        friend class ArcLruPart;
        template <typename K, typename V>
        friend class ArcLfuPart;

    private:
        Key key_;
        Value value_;

        size_t accessCount_;

        std::shared_ptr<ArcNode> prev_;
        std::shared_ptr<ArcNode> next_;
    };

} // namespace CachePool

#endif // ARC_NODE_HPP